<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/include/header.jsp"%>
</head>
<body>
        <div class="clearfix">
			<form id="${simpleBeanName}Form">
				<input type="hidden" name="CSRFToken" value="<hna:csrfToken />" />
				<input type="hidden" name="${columnList[0].javaPropertyName}" value="${r"${"}${simpleBeanName+"."+columnList[0].javaPropertyName}${r"}"}" />
				<table class="c_table m_t10">
						<#list columnList as column>
						<tr>
							<td class="t_tit">${column.dbColumnComment}：</td>
							<td><input type="text" class="input_txt" id="${column.javaPropertyName}" name="${column.javaPropertyName}" data-validaterole="${column.javaPropertyName}" data-rule="${column.javaPropertyName}" value="${r"${"}${simpleBeanName+"."+column.javaPropertyName}${r"}"}" data-param='{"code" : "mmm","ml":${column.dbColumnPrecision}}' data-message='最大不能超过<!=ml!>' /></td>
						</tr>					
						</#list>
				</table>					
			</form>
		</div>
		<div class="action_box m_t10 t_c">
			<input type="button" class="save_btn" id="editBtn" value="保存" />
		</div>
<script type="text/javascript">
	// 验证
	seajs.use(["component/validate", "component/tip"], function(validate, tip) {
	
		var ntip = function() {
			return commonUtils.getTip(tip);
		};	
		var d =  commonUtils.getValidate("${simpleBeanName}Form", "editBtn", ntip, validate);
		// 设置拼装规则: 这里加上各个验证规则
		<#list columnList as column>
		d.setValidateRule({ ${column.javaPropertyName}: ["isBlank", "checkLen"] });
		</#list>
	
		// 注册保存按钮事件
		d.bind("onsubmit", function() {
			var serializedForm = $("#${simpleBeanName}").serialize();		
			commonUtils.postAjax("${ctx}/${simpleBeanName}/edit.do", serializedForm, function(result){
				if (999 == result.code) {// 业务错误
					alert(result.msg);
				}
				if (200 == result.code) {
					alert("操作成功");
					parent.search();
					parent.${simpleBeanName}Dialog.close();
				}
			});
		});
	});
</script>
</body>
</html>